<%@ page contentType="text/html;charset=UTF-8" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> 
<%@ taglib prefix="tags" tagdir="/WEB-INF/tags" %>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>

<html>
<head>
    <title>_库龄查询</title>
    
	
	<script type="text/javascript">
		var tables_warehouseAge = null;
		$(function(){
			//初始化dataTables-plan
	        tables_warehouseAge=$("#table_warehouseAge").dataTable({
	           "bServerSide":true,
	           "sAjaxSource":'${ctx}/warehouseAge/v2_warehouseAgeQueryAjax',
	           "fnServerData": retrieveData_warehouseAge,
	           "bFilter": false,
	           "bSort": false,
	           "sZeroRecords": "查询无记录！",
	           "bProcessing": true,
	           "oLanguage": {
	               "sUrl": '${ctx}/static/v2/js/plugins/datatables/cn.txt'
	            },
	            "aoColumns": [
					{"mData": 'customerCode'},
					{"mData": 'warehouseCode'},
					{"mData": 'sku'},
					{"mData": 'opeTime',"render": function (obj) {
                        var time=obj.time;
                        var date = new Date(time);
                        return date.Format("yyyy-MM-dd");
                     }},
					{"mData": 'startTime',"render": function (obj) {
                        var time=obj.time;
                        var date = new Date(time);
                        return date.Format("yyyy-MM-dd");
                     }},
					{"mData": 'endTime',"render": function (obj) {
                        var time=obj.time;
                        var date = new Date(time);
                        return date.Format("yyyy-MM-dd");
                     }},
					{"mData": 'overNum'},
					{"mData": 'overDay'},
					{"mData": 'endFlag',"render": function (obj) {
                        var endFlag=obj;
                        
                        return (endFlag?"已结束超时状态":"<font color='red'>未结束超时状态</font>");
                     }}
	           ]
	        });
		});
		function retrieveData_warehouseAge(sSource, aoData, fnCallback){
			//查询参数
		   var customerCode=$("#customerCode").val();
		   aoData.push( { "name": "customerCode", "value": customerCode } );  
		    
		   var warehouseCode=$("#warehouseCode").val();
		   aoData.push( { "name": "warehouseCode", "value": warehouseCode } );
		   
		   var sku=$("#sku").val();
		   aoData.push( { "name": "sku", "value": sku } );
		   
		   var endFlag=$("#endFlag").val();
		   aoData.push( { "name": "endFlag", "value": endFlag } );
		   
		   $.ajax({ 
		       "type": "post",
		       "contentType": "application/json", 
		       "url": sSource,    
		       "dataType": "json",   
		       "data": JSON.stringify(aoData),
		       "success": function(resp) {  
	       			fnCallback(resp);
	       		}
		   }); 
		}
		
		function query() {
			tables_warehouseAge.fnDraw();
// 			tableTables_warehouseAge("action","${ctx}/warehouseAge/v2_warehouseAgeQuery");
// 			 $("#queryForm").submit();
		}
		
		 function exportGoodsAge(){
			 $("#queryForm").attr("action","${ctx}/warehouseAge/exportGoodsAgeExcell");
		     $("#queryForm").submit();
		  }
		 
    </script>
</head>

<body>
<div id="fullbg"></div>
<div id="dialog">
	<div>
		<img src="${ctx}/static/022.gif"></img>
	</div>
</div>
<section class="content">
    <!-- 查询条件  start-->
   	<div class="row">
	<div class="col-md-12">

			<!-- Primary box -->
			<div class="box box-solid box-primary" >
			    
				<div class="box-header">
					<i class="fa fa-search"></i>
					<h3 class="box-title">搜索栏</h3>
				</div>
				
				<div class="box-body">
				    <form class="form-search" id="queryForm" method="post" action="${ctx}/warehouseAge/v2_warehouseAgeQuery" style="margin-top: 10px;">
					    <!-- 第一行 -->
						<div class="form-group row">
							<div class="col-sm-3">
								<div class="input-group col-sm-12">
									<span class="input-group-text"> 商家名称： </span> 
									<select class="form-control" id="customerCode" name="customerCode" onchange="ajaxAreaGroup(this,'warehouseCode')">
										<option value=""></option>
										<c:forEach items="${customerList}" var="customer">
											<option value="${customer.customerCode}"
												<c:if test="${customerCode eq customer.customerCode}">selected=selected</c:if>>${customer.customerName}</option>
										</c:forEach>
									</select>
								</div>
							</div>
							
							<div class="col-sm-3">
								<div class="input-group col-sm-12">
									<span class="input-group-text"> 仓库： </span> 
									<select class="form-control" id="warehouseCode" name="warehouseCode" >
										<option value=""></option>
										<c:forEach items="${warehouseList}" var="warehouse">
											<option value="${warehouse.groupCode}"
												<c:if test="${warehouseCode eq warehouse.groupCode}">selected=selected</c:if>>${warehouse.groupName}</option>
										</c:forEach>
									</select>
								</div>
							</div>
							
							<div class="col-sm-3">
								<div class="input-group col-sm-12">
									<span class="input-group-text"> SKU： </span> 
									<input  class="form-control" id="sku" name="sku" value="${sku}">
								</div>
							</div>
							
							<div class="col-sm-3">
								<div class="input-group col-sm-12">
									<span class="input-group-text"> 当前状态： </span> 
									<select class="form-control" id="endFlag" name="endFlag" >
										<option value="">所有</option>
										<option value="1">已结束超时状态</option>
										<option value="0">未结束超时状态</option>
									</select>
								</div>
							</div>
							
						</div>
						<div class="form-group row">
							<div class="col-sm-6">
								<button class="btn btn-info" type="button" onclick="query();">搜索</button>
								<button class="btn btn-info" type="button" style="margin-left: 10px;" onclick="exportGoodsAge();">导出库龄信息</button>
							</div>
						</div>
					</form>
				</div>

			</div>

	 </div>
	</div>
    <!-- 查询条件 end -->
    
    <!-- 查询结果 start -->
	<div class="form-group row" >
		<div class="col-md-12">
	       <div class="box box-primary">
				 <div class="box-header"></div>
				 <div class="box-body table-responsive">
				     <table id="table_warehouseAge" class="table table-bordered table-striped">
				         <thead>
				             <tr>
				                <th style="width: 80px;">商家编码</th>
							    <th style="width: 80px;">仓库编码</th>
							    <th style="width: 80px;">SKU</th>
							    <th style="width: 80px;">入库时间</th>
							    <th style="width: 80px;">超时开始时间</th>
								<th style="width: 150px;">超时结束时间</th>
								<th style="width: 100px;">超龄数量</th>
								<th style="width: 100px;">超时天数</th>
								<th style="width: 100px;">当前状态</th>
				             </tr>
				         </thead>
<!-- 				         <tbody> -->
<%-- 				         	<c:forEach items="${soiList}" var="soi" varStatus="i"> --%>
<!-- 				         		<tr> -->
<%-- 				         			<td>${soi.customerCode}</td> --%>
<%-- 				         			<td>${soi.warehouseCode}</td> --%>
<%-- 				         			<td>${soi.sku}</td> --%>
<%-- 				         			<td>${soi.opeTimeStr}</td> --%>
<%-- 				         			<td>${soi.startTimeStr}</td> --%>
<%-- 				         			<td>${soi.endTimeStr}</td> --%>
<%-- 				         			<td>${soi.overDay}</td> --%>
<%-- 				         			<td>${soi.overNum}</td> --%>
<!-- 				         			<td> -->
<%-- 				         				<c:if test="${soi.endFlag}"> --%>
<!-- 				         					已结束超时状态 -->
<%-- 				         				</c:if> --%>
<%-- 				         				<c:if test="${!soi.endFlag}"> --%>
<!-- 				         					未结束超时状态 -->
<%-- 				         				</c:if> --%>
<!-- 				         			</td> -->
<!-- 				         		</tr> -->
<%-- 				         	</c:forEach> --%>
<!-- 				         </tbody> -->
				     </table>
				 </div>
			 </div>
		
		</div>
	</div>
	
</section>     
</body>
</html>
